/**
 * Created by yesi on 15/4/15.
 */

var pageSize = 20;

function getContent(url,data,async,processFun){
    return httpCallContent(url,data,"get",async,processFun);
}

function postContent(url,data,async,processFun){
    return httpCallContent(url,data,"post",async,processFun);
}

function httpCallContent(url,data,type,async,processFun){
    var rdata = null;
    $.ajax({
        url: url,
        datatype: 'json',
        async : async,
        type: type,
        data: data,
        success: function (receiveData) {
            rdata = processReceiveData(receiveData);
            if(processFun!=null){
                processFun(rdata);
            }
        }
    });
    return rdata;
}

function processReceiveData(receiveData){
    var dataJson = null;
    if(typeof(receiveData) == "object"){
        dataJson = receiveData;
    }else{
        dataJson = JSON.parse(receiveData);
    }
    var status = dataJson.status;
    if( status == 0){
        var msg = dataJson.msg;
        alert(msg);
        return  null;
    }else{
        return  dataJson.data;
    }
}
